An easy-to-use UI widget library for pygame, featuring customizable buttons, sliders, text entries, screen management and much more.
- easy integration: seamlessly works with existing pygame projects
- customizable widgets: nearly infinite styling options for colors, sounds, cursors, and more
- screen management: built-in screen system for creating different GUIs
pip install easypygamewidgetspython3 -m pip install easypygamewidgetsimport pygame
import easypygamewidgets as epw
pygame.init()
window = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()
# link the pygame window
epw.link_pygame_window(window)
# create a button
button = epw.Button(text="Click Me!")
button.place(300, 100)
# create a slider
slider = epw.Slider(text="Volume", start=0, end=100, auto_size=False, width=300)
slider.place(300, 200)
# create a text entry
entry = epw.Entry(placeholder_text="Type here...", auto_size=False, width=250)
entry.place(300, 400)
def draw():
window.fill((30, 30, 30))
# main game loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# handle widget events
epw.handle_event(event)
# handle special widget events
epw.handle_special_events()
# draw all widgets
epw.flip(draw)
pygame.display.update()
clock.tick(60)
pygame.quit()All examples will use the same start template code.
A container for managing groups of widgets with shared visibility and state.
A customizable button widget to run commands when interacted.
A slider for selecting values within a specific range.
A text entry with selection and clipboard support.
A text display that can be used to drag it into places or show text.
This converts your pygame surfaces into an easypygamewidgets widget that can be used in screens. (All pygame surface commands can be applied to the "surface" attribute of your widget.)
A text display that can show a timer or stopwatch.
A text display that is only shown when you hover over a widgets.
# link your pygame window (required before using widgets)
epw.link_pygame_window(pygame_window)
# handle pygame events (call in event loop)
epw.handle_event(pygame_event)
# handle special events (call outside event loop)
epw.handle_special_events()
# draw all widgets to the linked window
epw.flip()Check the examples directory for complete working examples:
- all widgets example - simple demo of all widgets
- screens with animations - multiple screens with transitions
- settings screen - interactive settings panel with sliders
- login form - form with entries and validation
- bindings - binding events to widgets
- python
- pygame
- requests (for update checking in background once)
I recommend using the latest version of libraries.
Contributions are welcome! Please feel free to submit a pull request. Of course will be mentioned :)
This project is licensed under the MIT License - see the LICENSE file for details.
-
Issues: GitHub Issues
-
Discord: My Account
-
Instagram: My Account
-
License: MIT
-
History: GitHub History
Made with ❤️ by PizzaPost